package com.xidian.zhiancloud.util.tools;

import lombok.Data;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 查询参数
 *
 * @author lill
 */
@Data
public class Query extends LinkedHashMap<String, Object> {
    private static final long serialVersionUID = 1L;
    //当前页码
    private int page;
    //每页条数
    private int size = 10;

    public Query(Map<String, Object> params) {
        this.putAll(params);

        //分页参数
        if (params.containsKey("page") && params.containsKey("size")) {
            this.page = Integer.parseInt(params.get("page").toString());
            this.size = Integer.parseInt(params.get("size").toString());
            this.put("current", (page - 1) * size);
            this.put("page", page);
            this.put("size", size);
        }

    }

}
